#include <iostream>
#include <stdio.h>
#include <string.h>
//#include <math.h>
using namespace std;

char  inmap[12][12];
double outmap[12][12];
int r,c;

void count()
{
    int i,j,lin;
    double sum;
    lin = '0'*4;
    for (i=1; i<r; ++i)
    {
        for (j=0; j<c-1; ++j)
        {
            sum = inmap[i][j] + inmap[i][j+1] + inmap [i+1][j] + inmap[i+1][j+1]-lin;
            outmap[i][j] = (int)sum/4;
        }    
    }       
}    

void output()
{
    int i,j;
    for (i=1; i<r; ++i)
    {
    	for (j=0; j<c-1; ++j)
    		printf("%.0lf", outmap[i][j]);
   		printf("\n");
    }    	
}   
int main()
{
	char ss[20];
	int i;

	while (1)
	{
	    scanf("%s", ss);
	    if (ss[0]=='E') break;
	    scanf("%d%d", &r, &c);
	    for (i=1; i<=r; ++i)
	    	scanf("%s", inmap[i]);
    	
    	count();
    	output();
    	
	    scanf("%s", ss);
	}    
    
    return 0;
}    


